home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_06 / 1106120a < prev    next >
Text File  |  1993-04-10  |  731b  |  50 lines

  1. #include <iostream.h>
  2.  
  3. class XXX { ... };
  4.  
  5. int f()
  6.     {
  7.     int i;
  8.     // ...
  9.     if (... something wrong ...)
  10.         throw 2;
  11.     }
  12.  
  13. int g()
  14.     {
  15.     XXX x;
  16.     unsigned long ul;
  17.     // ...
  18.     if (... something else wrong ...)
  19.         throw x;
  20.     return f();
  21.     }
  22.  
  23. int h()
  24.     {
  25.     try
  26.         {
  27.         // ...
  28.         g();
  29.         // ...
  30.         return 0;
  31.         }
  32.     catch (int n)
  33.         {
  34.         cerr << "# " << n << " happened\n";
  35.         return n;
  36.         }
  37.     catch (char *s)
  38.         {
  39.         cerr << s << " went wrong\n";
  40.         return -1;
  41.         }
  42.     catch (const XXX &x)
  43.         {
  44.         cerr << x << " went wrong\n";
  45.         return -1;
  46.         }
  47.     }
  48.  
  49.  
  50.